package qimao.com.edu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import qimao.com.edu.entity.CategoryMinor;
import qimao.com.edu.entity.CommenResult;
import qimao.com.edu.service.CategoryService;
import qimao.com.edu.service.impl.CategoryServiceImpl;

@WebServlet("/admin/selectCategory.do")
public class selectCategories extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("application/json;charset=UTF-8");
		
		CategoryService cs = new CategoryServiceImpl();
		List<CategoryMinor> MinorCategory = cs.getAllMinorCategories();
		
	    CommenResult cr = new CommenResult();
		cr.setCode(200);
		cr.setMsg("success");
		cr.setData(MinorCategory);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().write(cr.toJsonString());
	}
	
}
